local awful = require("awful")
local ass = awful.spawn

local wifi = {}

function wifi.switcher(sw)
    if sw then
        ass("rfkill unblock wifi")
    else
        ass("rfkill block wifi")
    end
end

function wifi.get()
    return io.popen("rfkill | grep wifi | cut -d ' ' -f 7"):read("*all")
end

function wifi.toggle()
    status = wifi.get()
    if status == "unblocked" then
        wifi.switcher(false)
    else
        wifi.switcher(true)
    end
end

return wifi
